using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using TTDotNet.Engine.Vehicles;

namespace TTDotNet.Engine.Companies
{
    public class Company
    {
        private string companyName;
        private string managerName;
        private DateTime inaugDate;
        private Color companyColor;
        private decimal companyFunds;

        private Fleet fleet;

        public Company(DateTime creationDate)
        {
            companyName = "Adam Miles Transport";
            managerName = "Adam Miles";
            inaugDate = creationDate;
            companyColor = Color.Blue;
            companyFunds = 100000;

            fleet = new Fleet();
        }

        public Fleet Fleet
        {
            get { return fleet; }
        }

        public string Name
        {
            get { return companyName; }
        }

        public decimal BankBalance
        {
            get { return Decimal.Round(companyFunds, 2); }
        }

        private void SetCompanyName(string name)
        {
            companyName = name;
        }

        private void SetManagerName(string name)
        {
            managerName = name;
        }

        private void SetColor(Color color)
        {
            companyColor = color;
        }

        public void AddVehicle(Vehicle vehicle)
        {
            fleet.Add(vehicle, vehicle.VehicleInformation.VehicleType);
        }

        public string GetCompanyName()
        {
            return companyName;
        }

        public void AddFunds(decimal moneyEarnt)
        {
            companyFunds += moneyEarnt;
        }

        public bool RemoveFunds(decimal moneyRequired, bool importance)
        {
            if (importance || moneyRequired < companyFunds)
            {
                companyFunds -= moneyRequired;
                return true;
            }
            else
            {
                return false;
            }
        }

        public void Update(float elapsedRealTime, TimeSpan elapsedGameTime)
        {
            fleet.Update(elapsedRealTime, elapsedGameTime);
        }

    }
}
